extends Control

# 信号
signal character_created(character_name: String)
signal creation_cancelled

@onready var name_input = $CenterContainer/MainPanel/ContentVBox/NameVBox/NameInput
@onready var confirm_button = $CenterContainer/MainPanel/ContentVBox/ButtonHBox/ConfirmButton
@onready var cancel_button = $CenterContainer/MainPanel/ContentVBox/ButtonHBox/CancelButton

func _ready() -> void:
	pass

# 确认按钮点击事件
func _on_confirm_button_pressed() -> void:
	var character_name = name_input.text.strip_edges()
	if character_name.is_empty():
		return
	
	# 发送角色创建信号
	character_created.emit(character_name)
	# 隐藏角色创建界面
	hide()
	# 清空输入
	name_input.text = ""

# 取消按钮点击事件
func _on_cancel_button_pressed() -> void:
	# 发送取消信号
	creation_cancelled.emit()
	# 隐藏角色创建界面
	hide()
	# 清空输入
	name_input.text = ""
